home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / Auth / Container / POP3.php < prev    next >
PHP Script  |  2004-03-24  |  3KB  |  108 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Stefan Ekman <stekman@sedata.org>                           |
  17. // |          Martin Jansen <mj@php.net>                                  |
  18. // |          Mika Tuupola <tuupola@appelsiini.net>                       |
  19. // +----------------------------------------------------------------------+
  20. //
  21. // $Id: POP3.php,v 1.3 2003/07/28 21:39:39 yavo Exp $
  22. //
  23.  
  24.  
  25. require_once('Auth/Container.php');
  26. require_once('PEAR.php');
  27. require_once('Net/POP3.php');
  28.  
  29. /**
  30.  * Storage driver for Authentication on a POP3 server.
  31.  *
  32.  * @author   Yavor Shahpasov <yavo@netsmart.com.cy>
  33.  * @package  Auth
  34.  * @version  $Revision: 1.3 $
  35.  */
  36. class Auth_Container_POP3 extends Auth_Container
  37. {
  38.     /**
  39.      * POP3 Server
  40.      * @var string
  41.      */
  42.     var $server='localhost';
  43.  
  44.     /**
  45.      * POP3 Server port
  46.      * @var string
  47.      */
  48.     var $port='110';
  49.  
  50.     // {{{ Constructor
  51.  
  52.     /**
  53.      * Constructor of the container class
  54.      *
  55.      * @param  $server string server or server:port combination
  56.      * @return object Returns an error object if something went wrong
  57.      */
  58.     function Auth_Container_POP3($server=null)
  59.     {
  60.         if(isset($server)){
  61.             if(is_array($server)){
  62.                 if(isset($server['host'])){
  63.                     $this->server = $server['host'];
  64.                 }
  65.                 if(isset($server['port'])){
  66.                     $this->port = $server['port'];
  67.                 }
  68.             }
  69.             else{
  70.                 if(strstr($server, ':')){
  71.                     $serverparts = explode(':', trim($server));
  72.                     $this->server = $serverparts[0];
  73.                     $this->port = $serverparts[1];
  74.                 }
  75.                 else
  76.                 {
  77.                     $this->server = $server;
  78.                 }
  79.             }
  80.         }
  81.     }
  82.  
  83.     // }}}
  84.     // {{{ fetchData()
  85.  
  86.     /**
  87.      * Try to login to the POP3 server
  88.      *
  89.      * @param   string Username
  90.      * @param   string Password
  91.      * @return  boolean
  92.      */
  93.     function fetchData($username, $password)
  94.     {
  95.         $pop3 =& new Net_POP3();
  96.         $res = $pop3->connect($this->server, $this->port);
  97.         if(!$res){
  98.             return($res);
  99.         }
  100.         $result = $pop3->login($username, $password);
  101.         $pop3->disconnect();
  102.         return $result;
  103.     }
  104.  
  105.     // }}}
  106. }
  107. ?>
  108.